package la.iok.hzsvn.lewin.movie.controller;

import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.lewin.movie.entity.*;
import la.iok.hzsvn.lewin.movie.service.AppFileService;
import la.iok.hzsvn.lewin.movie.service.WebDfsService;
import la.iok.hzsvn.lewin.mybatis.model.PageVo;
import la.iok.hzsvn.share.response.OperatorResponse;
import la.iok.hzsvn.share.response.OperatorResponses;
import la.iok.hzsvn.share.response.SingleDataResponse;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("appFiles")
public class AppFileController {
    private final AppFileService appFileService;

    public AppFileController(AppFileService appFileService, WebDfsService webDfsService) {
        this.appFileService = appFileService;
    }

    @GetMapping("free")
    public SingleDataResponse<PageVo<AppFile>> freeFiles(int page, int limit, Integer fileDeleted){
        PageVo<AppFile> pageVo = appFileService.freeFiles(page, limit, fileDeleted);
        return new SingleDataResponse<>(pageVo);
    }

    @DeleteMapping("{id}")
    public OperatorResponse deleteFreeFile(@RequestHeader Token token, @PathVariable Long id){
        appFileService.deleteFreeFile(token, id);
        return OperatorResponses.success();
    }

}
